package com.zp.responsibility;/**
 * @description
 * @author zp
 * @created 2021/9/3 22:31
 */

/**
 * @author zp
 * @description
 * @created 2021/9/3 22:31
 */
public class ChainOfResponsibilityPatternDemo {
    public static void main(String[] args) {
        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.WARNING);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);
        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);
        AbstractLogger loggerChain = errorLogger;

        loggerChain.logMessage(AbstractLogger.INFO, "This is an information.");

        loggerChain.logMessage(AbstractLogger.WARNING,
                "This is a debug level information.");
//
        loggerChain.logMessage(AbstractLogger.ERROR,
                "This is an error information.");
    }
}
